<template>
  <div>
    <div>
      数组如下, 随机取出一个名字在页面显示
      <p>let arr = ["小花", "小明", "小可爱", "小王"]</p>
    </div>
    <button @click="Fn">随机生成一个名字</button>
    <span>{{ a }}</span>
  </div>
</template>

<script>
export default {
  data() {
    return {
      a: "",
      arr: ["小花", "小明", "小可爱", "小王"],
    };
  },
  methods: {
    Fn() {
      let i = parseInt(Math.random() * 4);
      this.a = this.arr[i];
    },
  },
};
</script>

<style></style>
